package com.zh.admin.user.controller;

import com.zh.admin.user.service.AdminService;
import com.zh.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private AdminService adminService;

    @RequestMapping("/login")
    public String login(User user, HttpSession session){
//        System.out.println("login = " + user);
        User login_user = adminService.login(user);
        if(login_user != null){
            session.setAttribute("admin",login_user);
            return "admin/login/home";
        }else{
            return "redirect:admin/login/login.jsp";
        }
    }

//    @RequestMapping("/logout")
//    public String logout(HttpSession session){
//        session.removeAttribute("admin");
//        return "redirect:index.jsp";
//    }

}
